/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.faesa.acervo.view.mbeans;

import br.faesa.acervo.business.ejb.CadastroBasicoSessionBeanLocal;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;

/**
 *
 * @author aluno.faesa
 */
@ManagedBean
public class UsuarioLogonManagedBean {

    private String login;
    private String senha;
    
     @EJB 
    private CadastroBasicoSessionBeanLocal ejb;
    
    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getSenha() {
        return senha;
    }

    public void setSenha(String senha) {
        this.senha = senha;
    }
    
    public UsuarioLogonManagedBean() { }
    
    @PostConstruct
    public void init()
    {
//        Object o = FacesContext.getCurrentInstance().getExternalContext();
    }
    
    public String onBotaoOKClick()
    {
        System.out.print(getLogin());
        System.out.print(getSenha());
        System.out.print(ejb.verifivarLoginSenha(getLogin(), getSenha()));
        
        if (ejb.verifivarLoginSenha(getLogin(), getSenha()))
        {
            return "/principalForm.xhtml?faces-redirect=true";
        }
        
        return null;
    }
    
}
